package com.team11.server.controller.admin;

import com.team11.server.service.admin.Admin_UpdatePleader_Service;
import com.team11.server.service.admin.Admin_UpdateSInP_Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
@CrossOrigin
@RestController
@Api(tags = "管理员接口")
public class Admin_UpdateSInP_Controller {
    @Autowired
    private Admin_UpdateSInP_Service admin_updateSInP_service;
    @Autowired
    private Admin_UpdatePleader_Service admin_updatePleader_service;
    @ApiOperation("更换分组(需要当前项目组和新项目组id、学号)")
    @PostMapping("/UpdateSInP")
    public String updateSInP(Integer pId,Integer NewPid,String sNumber){
        HashMap<String,Object> map=new HashMap<>();
        map.put("pId",pId);
        map.put("NewPid",NewPid);
        map.put("sNumber",sNumber);
        String s=admin_updatePleader_service.SelSInP(map);
        if (s.equals("1")) {
            return "学员已在该小组";
        }else
            if(sNumber.equals(admin_updateSInP_service.SelPleader(pId))){
                admin_updateSInP_service.UpdatePleader(pId);
        }
        return admin_updateSInP_service.updateSInP(map);

    }
}
